package com.twu.biblioteca.view;

import com.twu.biblioteca.model.Book;

import java.util.List;

/**
 * Created by andreas on 21.04.14.
 */
public class BookListView {
    public String render(List<Book> books) {
        String format = "%-4s %-20s %-20s";
        StringBuilder sb = new StringBuilder(String.format(format, "ID", "AUTHOR", "TITLE").trim() + "\n");
        for (Book book : books) {
            sb.append(String.format(format, book.getID(), book.getAuthor(), book.getTitle()));
            sb.append("\n");
        }
        return sb.toString().trim();
    }
}
